﻿namespace TfsCloudDeploy.Workflow.Core.Activities
{
    using System;
    using System.Security.Permissions;
    using Microsoft.Win32.SafeHandles;

    /// <summary>
    /// Reflected from: Microsoft.TeamFoundation.ServiceHandle.
    /// Assembly: Microsoft.TeamFoundation.Common, Version=10.0.0.0.
    /// </summary>
    [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]
    internal sealed class ServiceHandle : SafeHandleZeroOrMinusOneIsInvalid
    {
        // Methods
        internal ServiceHandle()
            : base(true)
        {
        }

        protected override bool ReleaseHandle()
        {
            if (base.handle != IntPtr.Zero)
            {
                bool flag = NativeMethods.CloseServiceHandle(base.handle);
                base.handle = IntPtr.Zero;
                return flag;
            }
            return false;
        }
    }
}
